<?php
/**
 * Copyright © 2016 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */

// @codingStandardsIgnoreFile

/** @var \Magento\Review\Block\Customer\View $block */

$product = $block->getProductData();
?>
<?php if ($product->getId()): ?>
<div class="customer-review view">
    <div class="product-details">
        <div class="product-media">
            <a class="product-photo" href="<?php echo $block->escapeUrl($product->getProductUrl()) ?>">
                <?php /* customer_account_product_review_page */ ?>
                <?php echo $block->getImage($block->getProductData(), 'customer_account_product_review_page')->toHtml() ?>
            </a>
        </div>
        <div class="product-info">
            <h2 class="product-name"><?php echo $block->escapeHtml($product->getName()) ?></h2>
            <?php if ($block->getRating() && $block->getRating()->getSize()): ?>
                <span class="rating-average-label"><?php echo $block->escapeHtml(__('Average Customer Rating:')) ?></span>
                <?php echo $block->getReviewsSummaryHtml($product) ?>
            <?php endif; ?>
        </div>
    </div>

    <div class="review-details">
        <?php if ($block->getRating() && $block->getRating()->getSize()): ?>
            <div class="title">
                <strong><?php echo $block->escapeHtml(__('Your Review')); ?></strong>
            </div>
            <div class="customer-review-rating">
                <?php foreach ($block->getRating() as $_rating): ?>
                <?php if ($_rating->getPercent()): ?>
                    <?php $rating = ceil($_rating->getPercent()) ?>
                    <div class="rating-summary item">
                        <span class="rating-label"><span><?php echo $block->escapeHtml($_rating->getRatingCode()) ?></span></span>
                        <div class="rating-result" title="<?php /* @noEscape */ echo $rating; ?>%">
                            <span style="width:<?php /* @noEscape */ echo $rating; ?>%">
                                <span><?php /* @noEscape */ echo $rating; ?>%</span>
                            </span>
                        </div>
                    </div>
                <?php endif; ?>
                <?php endforeach; ?>
            </div>
        <?php endif; ?>

        <div class="review-title"><?php echo $block->escapeHtml($block->getReviewData()->getTitle()) ?></div>
        <div class="review-content"><?php echo nl2br($block->escapeHtml($block->getReviewData()->getDetail())) ?></div>
        <div class="review-date">
            <?php echo $block->escapeHtml(__('Submitted on %1', '<time class="date">' . $block->dateFormat($block->getReviewData()->getCreatedAt()) . '</time>'), ['time']) ?>
        </div>
    </div>
</div>
<div class="actions-toolbar">
    <div class="secondary">
        <a class="action back" href="<?php echo $block->escapeUrl($block->getBackUrl()) ?>"><span><?php echo $block->escapeHtml(__('Back to My Reviews')) ?></span></a>
    </div>
</div>
<?php endif; ?>
